part of 'fragment.dart';

class _AccountOverviewFragmentWloc
    extends StatefulWloc<_AccountOverviewFragmentWlocState, AccountOverviewFragment>
    with SingleTickerProviderStateMixin {
  late final AccountOverviewFragmentBloc _bloc;

  @override
  _AccountOverviewFragmentWlocState get initialState {
    return _AccountOverviewFragmentWlocStateFactory().create(
      blocState: _bloc.state,
    );
  }

  void _onStateChanged({
    required AccountOverviewFragmentBlocState blocState,
  }) {
    final updatedState = _AccountOverviewFragmentWlocStateFactory().create(
      blocState: blocState,
    );

    emit(updatedState);
  }

  @override
  void initState() {
    super.initState();

    _bloc = AccountOverviewFragmentBloc(
      authBloc: core_di.sl(),
      getAccountOverviewData: account_di.sl(),
    );

    _bloc.load();
  }

  @override
  void dispose() {
    _bloc.close();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return BlocListener<AccountOverviewFragmentBloc, AccountOverviewFragmentBlocState>(
      bloc: _bloc,
      listener: (context, state) {
        _onStateChanged(
          blocState: state,
        );
      },
      child: _AccountOverviewFragmentView(
        wloc: this,
      ),
    );
  }
}
